<?php

namespace App\Common\Model;

use think\Model;

class Handle extends Model
{
    protected $name = 'handle';

    protected $append = [
        'hand_text',
    ];

    // 关联文件夹
    public function project(){
        return $this->belongsTo('app\common\model\Project', 'proid', 'id');
    }
    // 关联账号
    public function user(){
        return $this->belongsTo('app\common\model\User', 'userid', 'id');
    }
    public function getHandTextAttr($value, $data)
    {
        $hantype = !empty($data['handtype']) ? $data['handtype'] : '';

        $text = '';
        switch ($hantype) {
            case 'upload':
                $text = '上传';
                break;
            case 'download':
                $text = '下载';
                break;
            case 'delete':
                $text = '删除';
                break;
            case 'check':
                $text = '查看';
                break;
            default:
                $text = '未知操作';
        }

        return $text;
    }
}